//
//  AppDelegate.m
//  UI1_View_Label
//
//  Created by dllo on 15/11/6.
//  Copyright (c) 2015年 dllo. All rights reserved.
//

#import "AppDelegate.h"
#import "ViewController.h"

@interface AppDelegate ()

@end

@implementation AppDelegate

// 1, mrc下, 为关心引用计数的属性重写dealloc方法
- (void)dealloc
{
    [_window release];
    [super dealloc];
}


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

    // 代码写在此处
    // 查看新类的步骤:1, 先看继承于谁; 2, 查看初始化方法,一般初始化方法都在第一个属性的上面,若类本身无初始化方法,则取调用父类的初始化方法
    
    // 4&4s : 320 x 480
    // 5&5s : 320 x 568
    // 6    : 375 x 667
    // 6plus: 414 x 736
    
    // 建立画板, 并设置坐标及大小
//    self.window = [[UIWindow alloc] initWithFrame:CGRectMake(0, 0, 414, 736)];
    
    // 画板一般与屏幕同尺寸,所以更兼容的写法为:
    // mainScreen当前主屏幕
    // bounds为CGRect结构体类型的属性, 通过getter方法获取当前主屏幕的坐标与尺寸
    self. window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    
    // 设置背景颜色
    self.window.backgroundColor = [UIColor grayColor];
    
    // 关联画板
    // 会引起引用计数增加
    [self.window makeKeyAndVisible];
    
    [_window release];
    
/*****************创建视图控制器,并将视图控制器添加到window的根视图控制器上*************/
    // 后面会详细讲解
    ViewController *rootVC = [[ViewController alloc] init];
    self.window.rootViewController = rootVC;
    [rootVC release];
    
    
    return YES;
}

- (void)applicationWillResignActive:(UIApplication *)application {
    // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
    // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}

- (void)applicationDidEnterBackground:(UIApplication *)application {
    // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
    // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}

- (void)applicationWillEnterForeground:(UIApplication *)application {
    // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
}

- (void)applicationDidBecomeActive:(UIApplication *)application {
    // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}

- (void)applicationWillTerminate:(UIApplication *)application {
    // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}

@end
